#include "TestCommon.h"
#include "FastDB/IndexDB.h"

BOOST_AUTO_TEST_SUITE(TestIndexDB)

BOOST_AUTO_TEST_CASE(TestIndexDBMain)
{
	FileSystem_Init();

	unlink("./test-index.db");
	IndexDB myTest("./test-index.db");

	SizeType iFile1 = myTest.CreateFile(1, 2);
	BOOST_REQUIRE(0 == iFile1);
	SizeType iFile2 = myTest.CreateFile(3, 4);
	BOOST_REQUIRE(1 == iFile2);

	BOOST_REQUIRE(1 == myTest.GetFirstRecord(0));
	BOOST_REQUIRE(2 == myTest.GetLastRecord(0));
	BOOST_REQUIRE(3 == myTest.GetFirstRecord(1));
	BOOST_REQUIRE(4 == myTest.GetLastRecord(1));

	sFileRecord myRecord;
	BOOST_REQUIRE(myTest.GetFileRecord(0, myRecord));
	BOOST_REQUIRE(1 == myRecord.iFirstRecordID);
	BOOST_REQUIRE(2 == myRecord.iLastRecordID);
	BOOST_REQUIRE(myTest.GetFileRecord(1, myRecord));
	BOOST_REQUIRE(3 == myRecord.iFirstRecordID);
	BOOST_REQUIRE(4 == myRecord.iLastRecordID);

    FileSystem_Free();
};

BOOST_AUTO_TEST_SUITE_END()
